<?php
/* @var $this PurchaseOrderDetailsController */
/* @var $model PurchaseOrderDetails */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'purchase-order-details-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<?php
		if(isset($_GET['id'])){
		echo '<div class="row" style="display:none;">'; 
		}else{
    	echo '<div class="row">';
		}
	?>
	<?php echo $form->labelEx($model,'purchase_order_id'); ?>
	<?php $name = array();
	        $model1 = PurchaseOrder::model()->findAll();
	        foreach ($model1 as $model2)
			$name[$model2->id] = $model2->id;
			echo $form->dropDownList($model, 'purchase_order_id', $name,
			array('prompt' => 'Select a Purchase Order No.')); ?>
			<?php if(isset($_GET['id'])){
				echo $form->textField($model,'purchase_order_id',array('size'=>45,'maxlength'=>45, 'value'=>$_GET['id']));
			}
			echo $form->error($model,'purchase_order_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'item_id'); ?>
		<?php echo $form->dropDownList($model, 'item_id', CHtml::listData(Item::model()->findAll(), 'id', 'item_desc'),	array('prompt' => 'Select an Item')	); ?>
		<?php echo $form->error($model,'item_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'qty'); ?>
		<?php echo $form->textField($model,'qty'); ?>
		<?php echo $form->error($model,'qty'); ?>
	</div>



	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->